var Tools = {
  alert: () => {
    alert(1)
  },
  isNull: (o) => {
    for (let i in o) {
      if (o[i] === '' || o[i] === undefined) {
        return true
      }
    }
    return false
  },
  isUdf: (str) => {
    if (str === undefined) {
      return ''
    }
    return str
  },
  toNull: (o) => {
    for (let i in o) {
      o[i] = ''
    }
  },
  firstUpperCase: (str) => {
    // return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase())
    return str.substring(0, 1).toLocaleUpperCase() + str.substring(1)
  },
  getPropValue: (name, prop, needPropValue, arr) => {
    for (let i = 0; i < arr.length; i++) {
      if (arr[i][prop] === name) {
        return arr[i][needPropValue]
      }
    }
  },
  /**
   * 解决数组，对象 引用1问题
   * @obj   要复制对象
   */
  getNewObj: (obj) => {
    let temp = {}
    for (let i in obj) {
      temp[i] = obj[i]
    }
    return temp
  },
  getName: (arr, value) => {
    for (let i = 0; i < arr.length; i++) {
      if (arr[i].value === value) {
        return arr[i].name
      }
    }
    return ''
  },
  getValue: (arr, name) => {
    for (let i = 0; i <= arr.length; i++) {
      if (arr[i].name === name) {
        return arr[i].value
      }
    }
    return ''
  }
}
export default Tools
